﻿if(!$)
{
    $ = function(itemId)
    {
        return document.getEelmentById(itemId);
    }
}
//vml基类，定义了基本vml属性

function VmlShape()
{
    this.id           = "";
    this.name         = "";
    this.left         = 0;
    this.top          = 0;
    this.zIndex       = "0";
    this.classStyle   = "";
    this.strokeweight  = "1px";
    this.strokecolor   = "black";
    this.stroked      = false;
    this.OnMouseOver  = null;
    this.OnMouseClick = null;
    this.Container    = null;
    
    this.InitBase = function()
    {
        try
        {
            this.id           = arguments[0].id ? arguments[0].id : "";
            this.name         = arguments[0].name ? arguments[0].name : "";
            this.left         = arguments[0].left ? parseInt(arguments[0].left) : 0;
            this.top          = arguments[0].top ? parseInt(arguments[0].top) : 0;
            this.zIndex       = arguments[0].zIndex ? arguments[0].zIndex : "0";
            this.classStyle   = arguments[0].classStyle ? arguments[0].classStye : "";
            this.strokeweight = arguments[0].strokeweight ? arguments[0].strokeweight : "1px";
            this.strokecolor  = arguments[0].strokecolor ? arguments[0].strokecolor : "black";
            this.stroked      = arguments[0].stroked ? arguments[0].stroked : false;
            this.Container    = arguments[0].Container ? arguments[0].Container : $("allInfoDiv"); //此处需要prototype.js
            
            this.OnMouseOver  = arguments[0].OnMouseOver ? arguments[0].OnMouseOver : null;
            this.OnMouseClick = arguments[0].OnMouseClick ? arguments[0].OnMouseClick : null;
        }
        catch(e)
        {
            return false;
        }
    }

    this.Clear  = function() 
    {
        
    }
    
    this.Draw   = function(){};
    
    //清除图形,也可以在子类中重写此方法
    this.UnDraw = function()
    {
        var obj = $(this.id);
        if(obj)
        {
            this.Container.removeChild(obj);
        }
        //this.RemoveFromDrawList();
    };
    
    //将对象添加到重绘的队列内
    //在级数变换时，地图对象通过队列 调用 “对象.Draw()”来重绘图形
    //在清除时，地图对象通过队列调用 “对象.UnDraw()” 来清除图形
    //通常不需要显示调用此方法，Draw时会调用
    //所有继承的子类型可以重写此方法，但没有必要
    this.AddToReDrawList = function()
    {
        if(window.UserReDrawObj)
        {
            for(var i=0; i<window.UserReDrawObj.length; i++)
            {
                if(window.UserReDrawObj[i] == this) return;
            }
            window.UserReDrawObj.push(this);
        }
    }
    
    this.RemoveFromDrawList = function()
    {
        for(var i=0; i<window.UserReDrawObj.length; i++)
        {
            if(window.UserReDrawObj[i] == this) 
            {   
                UserReDrawObj.splice(i, 1); //删除
                return;
            }
        }
    }
}

//===================================================================================
//    线、多边形实体图形,主要看传入的坐标了

//    继承了vml基本属性

//    并非所有属性必须，dotsArr和id请务必传入，其他根据需要而定
//    argument0: { id:"demo1", 
//            name:"demo1", 
//            zIndex: "1",
//            classStyle:"className", //样式
//            strokeweight: 1,    //线的粗

//            strokecolor: "red", //默认为black
//            stroked: true,      //默认为false
//            filled:true,        //默认为false，如果画线则不传，画多边形，则需要传此参数为true
//            fillcolor:blue,
//            OnMouseOver: mouseover,
//            onmouseClick: OnMouseClick,
//            dotsArr: D_Dot[],      //通常 此数组为逻辑坐标
//            Container: Container   //通常，此项不需要,默认为allInfoDiv
//          }
//===================================================================================
function PolyLineShape()
{
    this.options     = arguments[0];
    //自己的属性

    this.filled      = this.options.filled ? this.options.filled : false;
    this.fillcolor   = this.options.fillcolor ? this.options.fillcolor : "blue";
    this.fillopacity = this.options.fillopacity ? this.options.fillopacity : "0.5";
    this.dotArr      = arguments[0] ? arguments[0].dotArr : new Array();
    this.left        = this.dotArr[0].lx; //override
    this.top         = this.dotArr[0].ly; //override
    this.Content     = this.options.Content ? this.options.Content : "";//cxl0305
    
    //调用基类初始化方法

    this.InitBase(this.options ? this.options : null);
    
    this.Clear = function()
    {
        this.dotArr = null;
        this.dotArr = new Array();
    }
    this.ClearContent =function()//cxl0305
    {
        this.Content = "";
    }
    
    //绘制图形
    this.Draw = function()
    {
        if(this.dotArr.length == 0) return;
        var obj = $(this.id)
        if(!obj)
        {
            obj = document.createElement("v:shape");
            obj.id  = this.id;
            obj.style.position   = "absolute";
            obj.coordsize        = "50,50";
            obj.filled           = this.filled;
            obj.fillcolor        = this.fillcolor;
            obj.strokecolor      = this.strokecolor;
            obj.strokeweight     = this.strokeweight;
            obj.style.width      = "50px";
            obj.style.height     = "50px";
            obj.style.zIndex     = this.zIndex;
            obj.onmouseclick     = this.OnMouseClick;
            obj.onmoseover       = this.OnMouseOver;
            this.Container.appendChild(obj);
            var fillTag          = document.createElement("v:fill");
            fillTag.opacity      = this.fillopacity;
            obj.appendChild(fillTag);
        }
        var ContainerL = 0;
        var ContainerT = 0;
        try
        {
            if(this.Container.style.top != "")
                ContainerT = parseInt(this.Container.style.top);
            if(this.Container.style.left != "") 
                ContainerL = parseInt(this.Container.style.left);
        }
        catch(e)
        {
            ContainerL = 0;
            ContainerT = 0;
        }
        if(this.Content != "")//CXL0305_begin
        {
            var Xmax, Xmin, Ymax, Ymin;
            var SpanTop,SpanLeft,SpanSize; 
            var OneXy  = new Array();
            var szOneHtm = "" ;
            var xLoc,yLoc;
            for(var j = 0;j< this.dotArr.length;j++)
            {
               //逻辑坐标转换为窗口坐标
                logicXY = windowCoordinate(this.dotArr[j].lx, this.dotArr[j].ly,window.thisObj);
                xLoc = parseInt(logicXY[0]);
                yLoc = parseInt(logicXY[1]) ;
                if(j == 0)
                {
                     Xmax = xLoc; Xmin = xLoc; Ymax = yLoc; Ymin = yLoc;
                }
                if(j != 0)
                {
                    if(xLoc > Xmax)      { Xmax = xLoc; }
                    else if(xLoc < Xmin) { Xmin = xLoc; }
        		         
                    if(yLoc > Ymax)      { Ymax = yLoc; }
                    else if(yLoc < Ymin) { Ymin = yLoc; }
                }  
             } 
            //显示区域(名称)
            SpanLeft = (Xmax -  Xmin)*(1/3) + Xmin - ContainerL;
            SpanTop  = (Ymax -  Ymin)*(1/7) + Ymin - ContainerT;
            SpanSize = (Xmax -  Xmin)*(Ymax -  Ymin)/5000;
      
            szOneHtm +=  "<span style=POSITION:absolute;Z-INDEX:12;LEFT:"+SpanLeft+"px;TOP:";
            szOneHtm +=  SpanTop+"px;' ><font color='red' size='"+SpanSize/4+"px'>";
            szOneHtm +=  this.Content.split(",")[0] +"</font></span>";
      
            //显示参数(经营参数值)
            if(this.Content.split(",")[1].indexOf("*")>0)//净增，要显示三行
            {
                SpanLeft = (Xmax -  Xmin)*(1/3) + Xmin - ContainerL;
                SpanTop  = (Ymax -  Ymin)*(1/4) + Ymin - ContainerT;
                szOneHtm +=  "<span style=POSITION:absolute;Z-INDEX:12;LEFT:"+SpanLeft+"px;TOP:";
                szOneHtm +=  SpanTop+"px;WIDTH:250px;' ><font color='red' size='"+SpanSize/6+"px'>";
                szOneHtm +=  this.Content.split(",")[1].split("*")[2] +"</font></span>";
                
                SpanLeft = (Xmax -  Xmin)*(1/3) + Xmin - ContainerL;
                SpanTop  = (Ymax -  Ymin)*(3/8) + Ymin - ContainerT;
                szOneHtm +=  "<span style=POSITION:absolute;Z-INDEX:12;LEFT:"+SpanLeft+"px;TOP:";
                szOneHtm +=  SpanTop+"px;WIDTH:250px;' ><font color='red' size='"+SpanSize/6+"px'>";
                szOneHtm +=  this.Content.split(",")[1].split("*")[0] +"</font></span>";
                
                SpanLeft = (Xmax -  Xmin)*(1/3) + Xmin - ContainerL;
                SpanTop  = (Ymax -  Ymin)*(1/2) + Ymin - ContainerT;
                szOneHtm +=  "<span style=POSITION:absolute;Z-INDEX:12;LEFT:"+SpanLeft+"px;TOP:";
                szOneHtm +=  SpanTop+"px;WIDTH:250px;' ><font color='red' size='"+SpanSize/6+"px'>";
                szOneHtm +=  this.Content.split(",")[1].split("*")[1] +"</font></span>";
            }
            else//其他，显示一行
            {
                SpanLeft = (Xmax -  Xmin)*(1/3) + Xmin - ContainerL;
                SpanTop  = (Ymax -  Ymin)*(1/4) + Ymin - ContainerT;
                szOneHtm +=  "<span style=POSITION:absolute;Z-INDEX:12;LEFT:"+SpanLeft+"px;TOP:";
                szOneHtm +=  SpanTop+"px;WIDTH:250px;' ><font color='red' size='"+SpanSize/4+"px'>";
                szOneHtm +=  this.Content.split(",")[1] +"</font></span>";
            }
            
            var objC = $(this.id + "content");
            if(!objC)
            {
               objC = document.createElement("DIV");
               objC.id  = this.id + "content";
               this.Container.appendChild(objC);
            }
            objC.innerHTML  = szOneHtm;
            objC.style.left = SpanLeft - ContainerL + "px";
            objC.style.top  = SpanTop  - ContainerT + "px";
            objC.style.visibility = "visible";
        }//cxl0305_end
        if(this.dotArr[0].isLogic)
        {
            var wxy = window.windowCoordinate(this.dotArr[0].lx, this.dotArr[0].ly, window.thisObj);
            var referX = wxy[0];
            var referY = wxy[1];
            var vmlPath = "m " + 0 + "," + 0 + " l ";
            obj.style.left = wxy[0] - ContainerL + "px";
            obj.style.top  = wxy[1] - ContainerT + "px";
            for(var i=1; i<this.dotArr.length; i++)
            {
                wxy = window.windowCoordinate(this.dotArr[i].lx, this.dotArr[i].ly, window.thisObj);
                vmlPath += (wxy[0] - referX) + "," + (wxy[1] - referY) + " ";
            }
            vmlPath += "e";
            obj.path = vmlPath;
        }
        else
        {
            obj.style.left = this.dotArr[0].lx - ContainerL + "px";
            obj.style.top  = this.dotArr[0].ly - ContainerT + "px";
            var vmlPath = "m " + 0 + "," + 0 + " l ";
            for(var i=1; i<this.dotArr.length; i++)
            {
                vmlPath += (this.dotArr[i].lx - this.dotArr[0].lx) + "," + (this.dotArr[i].ly - this.dotArr[0].ly) + " ";
            }
            vmlPath += "e";
            obj.path = vmlPath;
        }
        obj.style.visibility = "visible";
        //将对象添加到重绘的队列内
        this.AddToReDrawList(); 
    }
    
    this.UnDraw = function()
    {
        var obj = $(this.id);
        if(obj)
        {
            this.Container.removeChild(obj);
        }
        var objC = $(this.id + "content");
        if(objC)
        {
            this.Container.removeChild(objC);
        }
    }
    
    this.GetLogicDots = function()
    {
        if(this.dotArr == null || this.dotArr.length == 0) return null;
        if(this.dotArr[0].isLogic)
            return this.dotArr.clone();
        var dots = new Array();
        for(var i=0; i<this.dotArr.length; i++)
        {
            var lxy = window.logicCoordinate(this.dotArr[i].lx, this.dotArr[i].ly, thisObj);
            dots[i] = new D_Dot2D(lxy[0], lxy[1], true);
        }
        return dots;
    }
}
PolyLineShape.prototype = new VmlShape();



function VmlBeeline()
{
    this.options     = arguments[0];
    
    //自己的属性

    //一段直线段两个端点，在这里可以为多跳线段的数组， 则以1-2, 3-4, 5-6, 7-8...这样组合来Draw Line
    this.dotArr      = arguments[0] ? arguments[0].dotArr : new Array();
    
    this.left        = this.dotArr[0].lx; //override
    this.top         = this.dotArr[0].ly; //override
    
    //调用基类初始化方法

    this.InitBase(this.options ? this.options : null);
    
    this.Clear = function()
    {
        this.dotArr = null;
        this.dotArr = new Array();
    }
    
    this.CreateLineLayer = function(index)
    {
        var obj = $(this.id)

        obj      = document.createElement("v:line");
        obj.id   = this.id + "" + index;
        obj.name = this.name;
        obj.style.position   = "absolute";
        obj.strokecolor      = this.strokecolor;
        obj.strokeweight     = this.strokeweight;
        obj.style.zIndex     = this.zIndex;
        obj.onmouseclick     = this.OnMouseClick;
        obj.onmoseover       = this.OnMouseOver;
        obj.onmoseout        = this.OnMouseOut;
        this.Container.appendChild(obj);
        return obj;
    }
    
    //绘制图形
    this.Draw = function()
    {
        if(this.dotArr.length == 0 || this.dotArr.length % 2 == 1) return;

        var ContainerL = 0;
        var ContainerT = 0;
        try
        {
            if(this.Container.style.top != "")
                ContainerT = parseInt(this.Container.style.top);
            if(this.Container.style.left != "") 
                ContainerL = parseInt(this.Container.style.left);
        }
        catch(e)
        {
            ContainerL = 0;
            ContainerT = 0;
        }
        if(this.dotArr[0].isLogic)
        {
            var wxy = window.windowCoordinate(this.dotArr[0].lx, this.dotArr[0].ly, window.thisObj);
            var referX = wxy[0];
            var referY = wxy[1];
            //var vmlPath = "m " + 0 + "," + 0 + " l ";
            
            for(var i=0; i<this.dotArr.length/2; i++)
            {
                wxy1 = window.windowCoordinate(this.dotArr[2 * i].lx, this.dotArr[2 * i].ly, window.thisObj);
                wxy2 = window.windowCoordinate(this.dotArr[2 * i + 1].lx, this.dotArr[2 * i + 1].ly, window.thisObj);

                obj = this.CreateLineLayer(i);
                obj.style.left = wxy1[0] - ContainerL + "px";
                obj.style.top  = wxy1[1] - ContainerT + "px";
                obj.from = "0,0";
                offx = wxy2[0] - wxy1[0];
                offy = wxy2[1] - wxy1[1];
                obj.to   = offx + "," + offy;
            }
        }
        else
        {
            
            for(var i=0; i<this.dotArr.length/2; i++)
            {
                obj = this.CreateLineLayer(i);
                obj.style.left = this.dotArr[2*i].lx - ContainerL + "px";
                obj.style.top  = this.dotArr[2*i].ly - ContainerT + "px";
                obj.from = "0,0";
                offx = this.dotArr[2*i + 1].lx - this.dotArr[2*i].lx;
                offy = this.dotArr[2*i + 1].ly - this.dotArr[2*i].ly;
                obj.to   = offx + "," + offy;
            }
        }
        obj.style.visibility = "visible";
        //将对象添加到重绘的队列内
        this.AddToReDrawList(); 
    }
    
    //override
    this.UnDraw = function()
    {
        var objs = this.Container.childNodes;
        var objIds = new Array();
        for(var i=0; i<objs.length; i++)
        {
            if(objs[i].id.indexOf(this.id) != -1)
            {
                objIds.push(objs[i].id);
            }
        }
        for(var i=0; i<objIds.length; i++)
        {
            this.Container.removeChild($(objIds[i]));
        }
    };
    
    this.GetLogicDots = function()
    {
        if(this.dotArr == null || this.dotArr.length == 0 || this.dotArr.length % 2 == 1) return null;
        if(this.dotArr[0].isLogic)
            return this.dotArr.clone();
        var dots = new Array();
        for(var i=0; i<this.dotArr.length; i++)
        {
            var lxy = window.logicCoordinate(this.dotArr[i].lx, this.dotArr[i].ly, thisObj);
            dots[i] = new D_Dot2D(lxy[0], lxy[1], true);
        }
        return dots;
    }
}
VmlBeeline.prototype = new VmlShape();



//     圆实体图形类
//     继承了vml基本属性

//     并非所有属性必须，id和C_DOT及半径radius请务必传入，其他根据需要

//     argument0: { id:"demo1", 
//            name:"demo1",       
//            zIndex: "1",        //默认为0
//            classStyle:"className", //样式可以为空
//            strokeweight: 1,    //线的粗,默认为1
//            strokecolor: "red", //默认为black
//            stroked: true,      //默认为false
//            filled:true,        //默认为true
//            fillcolor:"blue",   //默认为blue
//            fillopacity:"0.5"   //默认为0.5
//            OnMouseOver: mouseover,     //可以为null
//            onmouseClick: OnMouseClick, //可以为null
//            C_Dot: D_Dot,      //通常 此数组为逻辑坐标
//            radius：radius，   //请跟dot保持一致，要么都为逻辑坐标
//            Container: Container   //通常，此项不需要,默认为allInfoDiv
//          }
function VmlCircle()
{
    this.options   = arguments[0];
    
    //自己的属性

    this.filled      = this.options.filled ? this.options.filled : true;
    this.fillcolor   = this.options.fillcolor ? this.options.fillcolor : "blue";
    this.fillopacity = this.options.fillopacity ? this.options.fillopacity : "0.5";
    this.C_Dot       = arguments[0] ? arguments[0].C_Dot : new D_Dot2D(0, 0, true);
    this.radius      = arguments[0] ? arguments[0].radius : 0;

    //调用基类初始化方法

    this.InitBase(this.options ? this.options : null);

    //绘制图形
    this.Draw = function()
    {
        if(!this.C_Dot) return;
        var obj = $(this.id)
        //创建vml层

        if(!obj)
        {
            obj = document.createElement("v:oval");
            obj.id  = this.id;
            obj.style.position   = "absolute";
            obj.filled           = this.filled;
            obj.fillcolor        = this.fillcolor;
            obj.strokecolor      = this.strokecolor;
            obj.strokeweight     = this.strokeweight;
            obj.style.zIndex     = this.zIndex;
            obj.onmouseclick     = this.OnMouseClick;
            obj.onmoseover       = this.OnMouseOver;
            this.Container.appendChild(obj);
            var fillTag          = document.createElement("v:fill");
            fillTag.opacity      = this.fillopacity;
            obj.appendChild(fillTag);
        }
        var ContainerL = 0;
        var ContainerT = 0;
        try
        {
            if(this.Container.style.top != "")
                ContainerT = parseInt(this.Container.style.top);
            if(this.Container.style.left != "") 
                ContainerL = parseInt(this.Container.style.left);
        }
        catch(e)
        {
            ContainerL = 0;
            ContainerT = 0;
        }
        if(this.C_Dot.isLogic)
        {
            this.left      = this.C_Dot.lx - this.radius; //override
            this.top       = this.C_Dot.ly + this.radius; //override
            var lp = window.windowCoordinate(this.left, this.top, window.thisObj);
            var cp = window.windowCoordinate(this.C_Dot.lx, this.C_Dot.ly, window.thisObj);
            obj.style.left       = lp[0] - ContainerL + "px";
            obj.style.top        = lp[1] - ContainerT + "px";
            obj.style.width      = Math.abs(cp[0] - lp[0])  * 2 + "px";
            obj.style.height     = Math.abs(cp[1] - lp[1]) * 2 + "px";
        }
        else
        {
            this.left            = this.C_Dot.lx - this.radius; //override
            this.top             = this.C_Dot.ly - this.radius; //override
            obj.style.left       = this.left - ContainerL + "px";
            obj.style.top        = this.top - ContainerT + "px";
            obj.style.width      = this.radius * 2 + "px";
            obj.style.height     = this.radius * 2 + "px";
        }
        obj.style.visibility = "visible";
        //将对象添加到重绘的队列内
        this.AddToReDrawList();
    }
    
    this.GetLogicDots = function()
    {
        if(this.C_Dot == null) return null;
        if(this.C_Dot.isLogic)
        {
            return new D_Circ( this.C_Dot.lx, this.C_Dot.ly, this.radius, true );           
        }
        var dots = new Array();
        dots[0] = this.C_Dot;
        dots[1] = new D_Dots2D(this.C_Dot.lx - this.radius, this.C_Dot.lx - this.radius, true);
        for(var i=0; i<dots.length; i++)
        {
            var lxy = window.logicCoordinate(dots[i].lx, dots[i].ly, thisObj);
            dots[i] = new D_Dot2D(lxy[0], lxy[1], true);
        }
        var r = Math.abs(dots[1].lx - dots[0].lx);
        return new D_Circ( dots[0].lx, dots[0].ly, r , true );
    }
}
VmlCircle.prototype = new VmlShape();


function ShapeRect()
{
    try
    {
        this.InitBase();
        
        this.id     = arguments[0].id ? arguments[0].id : "";
//        this.top    = arguments[0].top ? arguments[0].top : 0;
//        this.left   = arguments[0].left ? arguments[0].left : 0;
//        this.width  = arguments[0].width ? arguments[0].width : 0;
//        this.height = arguments[0].height ? arguments[0].height : 0;
        this.dotArr = arguments[0].dotArr ? arguments[0].dotArr : 0;
        
        this.strokeColor  = arguments[0].strokeColor ? arguments[0].strokeColor : "red";
        this.filledColor  = arguments[0].filledColor ? arguments[0].filledColor : "blue";
    }catch(e){}
    
    this.Draw = function()
    {
        if(this.dotArr == null || this.dotArr.length < 2) return;
        var obj = $(this.id);
        if(!obj)
        {
            obj = document.createElement("DIV");
            obj.id = this.id; 
            obj.style.zIndex = "5";
            obj.style.position = "absolute";
            obj.style.backgroundColor = this.filledColor;
            obj.style.border = this.strokeColor + " solid 1px";
            CtnBrowser.IE? obj.style.filter="alpha(opacity=50)" : obj.style.MozOpacity=0.5;
            this.Container.appendChild(obj);
        }
        var ContainerL = 0;
        var ContainerT = 0;
        try
        {
            if(this.Container.style.top != "")
                ContainerT = parseInt(this.Container.style.top);
            if(this.Container.style.left != "") 
                ContainerL = parseInt(this.Container.style.left);
        }
        catch(e)
        {
            ContainerL = 0;
            ContainerT = 0;
        }
        if(this.dotArr[0].isLogic)
        {
            var wxy1 = window.windowCoordinate(this.dotArr[0].lx, this.dotArr[0].ly, window.thisObj);
            var wxy2 = window.windowCoordinate(this.dotArr[1].lx, this.dotArr[1].ly, window.thisObj);
            
            this.left   = Math.min(wxy1[0], wxy2[0]);
            this.top    = Math.min(wxy1[1], wxy2[1]);
            this.width  = Math.abs(wxy1[0] - wxy2[0]);
            this.height = Math.abs(wxy1[1] - wxy2[1]);
        } 
        else
        {
            this.left   = Math.min(this.dotArr[0].lx, this.dotArr[1].lx);
            this.top    = Math.min(this.dotArr[0].ly, this.dotArr[1].ly);
            this.width  = Math.abs(this.dotArr[0].lx - this.dotArr[1].lx);
            this.height = Math.abs(this.dotArr[0].ly - this.dotArr[1].ly);
        }
        
        obj.style.left   = this.left - ContainerL  + "px";
        obj.style.top    = this.top  - ContainerT   + "px";
        obj.style.width  = this.width  + "px";
        obj.style.height = this.height + "px";
        //将对象添加到重绘的队列内
        this.AddToReDrawList();
    }
    
    this.GetLogicDots = function()
    {
        if(this.dotArr == null || this.dotArr.length == 0) return null;
        if(this.dotArr[0].isLogic)
            return this.dotArr.clone();
        var dots = new Array();
        for(var i=0; i<this.dotArr.length; i++)
        {
            var lxy = window.logicCoordinate(this.dotArr[i].lx, this.dotArr[i].ly, thisObj);
            dots[i] = new D_Dot2D(lxy[0], lxy[1], true);
        }
        return dots;
    }
    
    this.GetWindowDots = function()
    {
        if(this.dotArr == null || this.dotArr.length == 0) return null;
        if(!this.dotArr[0].isLogic)
            return this.dotArr.clone();
        var dots = new Array();
        for(var i=0; i<this.dotArr.length; i++)
        {
            var lxy = window.windowCoordinate(this.dotArr[i].lx, this.dotArr[i].ly, thisObj);
            dots[i] = new D_Dot2D(lxy[0], lxy[1], false);
        }
        return dots;
    }

    this.GetWindowCenXY = function()
    {
        if(this.dotArr == null || this.dotArr.length == 0) return null;
        if(!this.dotArr[0].isLogic)
        {
            var x = (this.dotArr[0].lx + this.dotArr[1].lx)/2;
            var y = (this.dotArr[0].ly + this.dotArr[1].ly)/2;
            return [x,y];
        }
        var dots = new Array();
        for(var i=0; i<this.dotArr.length; i++)
        {
            var lxy = window.windowCoordinate(this.dotArr[i].lx, this.dotArr[i].ly, thisObj);
            dots[i] = new D_Dot2D(lxy[0], lxy[1], false);
        }
        var x = (dots[0].lx + dots[1].lx)/2;
        var y = (dots[0].ly + dots[1].ly)/2;
        return [x,y];
    }
}
//作为vmlshape的派生类
ShapeRect.prototype = new VmlShape();

//点定位

function MDotLocalizer()
{
    
}

//===============创建绘线画笔(vml对象)============================
var dots = new Array();
dots[0] = new D_Dot2D(0,0,true);
dots[1] = new D_Dot2D(0,0,true);
arg = { id:"LinePen", 
        name:"LinePen", 
        zIndex: "3",
        classStyle:" ",
        strokeweight: 1, 
        strokecolor: "red", 
        stroked: true,
        OnMouseOver: null,
        onmouseClick: null,
        dotArr: dots
      }
window.LinePen = new PolyLineShape(arg);
window.LinePener = new DcLine();


arg = { id:"BeeLinePen", 
        name:"BeeLinePen", 
        zIndex: "5",
        classStyle:" ",
        strokeweight: 1, 
        strokecolor: "red", 
        stroked: true,
        OnMouseOver: null,
        onmouseClick: null,
        dotArr: dots
      }
window.BeeLinePen = new VmlBeeline(arg);
window.BeeLinePener = new DcBeeLine();

arg = { id:"PloyPen", 
        name:"PloyPen", 
        zIndex: "1",
        classStyle:" ",
        strokeweight: 1, 
        strokecolor: "red", 
        stroked: true,
        filled : true,
        OnMouseOver: null,
        onmouseClick: null,
        dotArr: dots
      }
window.PolyPen = new PolyLineShape(arg);
window.PolyPener = new DcPoly();

arg = { id:"CircPen", 
            name:"CircPen", 
            zIndex: "2",
            classStyle:" ",
            strokeweight: 1, 
            strokecolor: "black", 
            stroked: true,
            filled:true,
            C_Dot:dots[0],
            radius:0,
            OnMouseOver: null,
            onmouseClick: null
         }
window.CircPen = new VmlCircle(arg);
window.CircPener = new DcCirc();

arg = { id : "RectPen",
        name : "RectPen",
        dotArr : dots
      }
window.RectPen   = new ShapeRect(arg);
window.RectPener = new DcRect();

function getLinePenLogic()
{
    return window.LinePen.GetLogicDots();
}

function getPolyPenLogic()
{
    return window.PolyPen.GetLogicDots();
}

function getRectPenLogic()
{
    return window.RectPen.GetLogicDots();
}

function getCircPenLogic()
{
    return window.CircPen.GetLogicDots();
}

//手绘折线型对象
function DcLine()
{
    this.OnMouseDown = function(e)
    {
        e = e ? e : event;
        if(e.button == 1)
        {
            if(!this.DrawFlag) 
            {
                this.MouseTrack = null; 
                this.MouseTrack = new Array(); 
                this.DrawFlag = true;//画线的标志为真

            }
            var wx  = CtnBrowser.IE ? e.clientX : e.pageX;
            var wy  = CtnBrowser.IE ? e.clientY : e.pageY;
            var lxy = window.logicCoordinate(wx, wy, thisObj);
            this.MouseTrack[this.MouseTrack.length] = new D_Dot2D(lxy[0], lxy[1], true);
        }
        else if(e.button == 2)
        {
            if(this.DrawFlag)
            {
                this.MouseTrack = null; 
                this.MouseTrack = new Array(); 
                this.DrawFlag = false;//画线的标志为false
                this.PenDc.Clear();
                this.PenDc.UnDraw();
            }
        }
        
        
    };
    
    this.OnMouseMove = function(e)
    {
        e = e ? e : event;
        if(!this.DrawFlag) return;
        
        this.PenDc.dotArr = null;
        this.PenDc.dotArr = this.MouseTrack.clone();
        var wx  = CtnBrowser.IE ? e.clientX : e.pageX;
        var wy  = CtnBrowser.IE ? e.clientY : e.pageY;
        var lxy = window.logicCoordinate(wx, wy, thisObj);
        this.PenDc.dotArr[this.PenDc.dotArr.length] = new D_Dot2D(lxy[0], lxy[1], false);
        this.PenDc.Draw();
    };
    
    this.OnMouseUp = function(e)
    {
    
    };
    
    this.OnMouseDbClk = function(e)
    {
        e = e ? e : event;
        if(!this.DrawFlag) return;
        this.DrawFlag = false;
        this.PenDc.dotArr = this.MouseTrack.clone();
        //this.PenDc.dotArr.pop();
        this.MouseTrack = null;
        this.MouseTrack = new Array();
        this.PenDc.Draw();
    };
    
    this.MouseTrack = new Array();   //轨迹
    this.DrawFlag = false;
    
    this.PenDc = LinePen;  //画笔
}

//手绘直线型对象
function DcBeeLine()
{
    this.OnMouseDown = function(e)
    {
        e = e ? e : event;
        if(e.button == 1)
        {
            if(!this.DrawFlag) 
            {
                this.MouseTrack = null; 
                this.MouseTrack = new Array(); 
                this.DrawFlag = true;//画线的标志为真
                var dots = new Array();
                dots[0] = new D_Dot2D(0,0,true);
                dots[1] = new D_Dot2D(0,0,true);
                var d = new Date();
                var id = "BeeLinePen" + d.getMilliseconds();
                arg = { id : id, 
                        name : "BeeLinePen", 
                        zIndex : "5",
                        classStyle :" ",
                        strokeweight : 1, 
                        strokecolor : "red", 
                        stroked : true,
                        OnMouseOver : null,
                        onmouseClick : null,
                        dotArr : dots
                      }
                //window.BeeLinePen = new VmlBeeline(arg);
                this.PenDc = new PolyLineShape(arg);
            }
            var wx  = CtnBrowser.IE ? e.clientX : e.pageX;
            var wy  = CtnBrowser.IE ? e.clientY : e.pageY;
            var lxy = window.logicCoordinate(wx, wy, thisObj);
            if(this.MouseTrack.length == 0)
            {
                this.MouseTrack[0] = new D_Dot2D(lxy[0], lxy[1], true);
            }
            else
            {
                this.MouseTrack[1] = new D_Dot2D(lxy[0], lxy[1], true);
                this.PenDc.dotArr = this.MouseTrack.clone();
                this.PenDc.Draw();
                this.DrawFlag = false;//画线的标志为false
            }
        }
        else if(e.button == 2)
        {
            if(this.DrawFlag)
            {
                this.MouseTrack = null; 
                this.MouseTrack = new Array(); 
                this.DrawFlag = false;//画线的标志为false
                this.PenDc.Clear();
                this.PenDc.UnDraw();
            }
        }
        
        
    };
    
    this.OnMouseMove = function(e)
    {
        e = e ? e : event;
        if(!this.DrawFlag) return;
        
        this.PenDc.dotArr = null;
        this.PenDc.UnDraw();
        this.PenDc.dotArr = this.MouseTrack.clone();
        var wx  = CtnBrowser.IE ? e.clientX : e.pageX;
        var wy  = CtnBrowser.IE ? e.clientY : e.pageY;
        var lxy = window.logicCoordinate(wx, wy, thisObj);
        this.PenDc.dotArr[1] = new D_Dot2D(lxy[0], lxy[1], false);
        this.PenDc.Draw();
    };
    
    this.OnMouseUp = function(e)
    {
    
    };
    
    this.OnMouseDbClk = function(e)
    {
    };
    
    this.MouseTrack = new Array();   //轨迹
    this.DrawFlag = false;
    
    this.PenDc = null;  //画笔
}

function DcPoly()
{
    this.OnMouseDown = function(e)
    {
        e = e ? e : event;
        if(e.button == 1)
        {
            if(!this.DrawFlag) 
            {
                this.MouseTrack = null; 
                this.MouseTrack = new Array(); 
                this.DrawFlag = true;//画线的标志为真

            }
            
            var wx  = CtnBrowser.IE ? e.clientX : e.pageX;
            var wy  = CtnBrowser.IE ? e.clientY : e.pageY;
            var lxy = window.logicCoordinate(wx, wy, thisObj);
            this.MouseTrack[this.MouseTrack.length] = new D_Dot2D(lxy[0], lxy[1], true);
        }
        else if(e.button == 2)
        {
            if(this.DrawFlag)
            {
                this.MouseTrack = null; 
                this.MouseTrack = new Array(); 
                this.DrawFlag = false;//画线的标志为真

                this.PenDc.Clear()
                this.PenDc.UnDraw();
            }
        }
    };
    
    this.OnMouseMove = function(e)
    {
        e = e ? e : event;
        if(!this.DrawFlag) return;
        
        this.PenDc.dotArr = null;
        this.PenDc.dotArr = this.MouseTrack.clone();
        var wx  = CtnBrowser.IE ? e.clientX : e.pageX;
        var wy  = CtnBrowser.IE ? e.clientY : e.pageY;
        var lxy = window.logicCoordinate(wx, wy, thisObj);
        this.PenDc.dotArr[this.PenDc.dotArr.length] = new D_Dot2D(lxy[0], lxy[1], true);
        this.PenDc.Draw();
    };
    
    this.OnMouseUp = function(e)
    {
    
    };
    this.OnMouseDbClk = function(e)
    {
        e = e ? e : event;
        if(!this.DrawFlag) return;
        this.DrawFlag = false;
        this.PenDc.dotArr = this.MouseTrack.clone();
        //this.PenDc.dotArr.pop();
        this.PenDc.dotArr[this.PenDc.dotArr.length] = this.PenDc.dotArr[0];
        this.MouseTrack = null;
        this.MouseTrack = new Array();
        this.PenDc.Draw();
        this.PenDc.UnDraw();
    };
    
    this.MouseTrack = new Array();   //轨迹
    this.DrawFlag = false;
    
    this.PenDc = PolyPen;
}

function DcCirc()
{
    this.OnMouseDown = function(e)
    {
        e = e ? e : event;
        if(!this.DrawFlag) 
        {
            this.PenDc.C_Dot = null; 
            this.PenDc.radius = 0;
            this.DrawFlag = true;//画线的标志为真

        }
        
        var wx  = CtnBrowser.IE ? e.clientX : e.pageX;
        var wy  = CtnBrowser.IE ? e.clientY : e.pageY;
        var lxy = window.logicCoordinate(wx, wy, thisObj);
        this.PenDc.C_Dot = new D_Dot2D(lxy[0], lxy[1], true);
        //this.MouseTrack[this.MouseTrack.length] = new D_Dot2D(lxy[0], lxy[1], true);
    };
    
    this.OnMouseMove = function(e)
    {
        e = e ? e : event;
        if(!this.DrawFlag) return;
        var wx  = CtnBrowser.IE ? e.clientX : e.pageX;
        var wy  = CtnBrowser.IE ? e.clientY : e.pageY;
        var lxy = window.logicCoordinate(wx, wy, thisObj);
        this.PenDc.radius = Math.sqrt((lxy[0] - this.PenDc.C_Dot.lx) * (lxy[0] - this.PenDc.C_Dot.lx) + (lxy[1] - this.PenDc.C_Dot.ly) * (lxy[1] - this.PenDc.C_Dot.ly));
        this.PenDc.Draw();
    };
    
    this.OnMouseUp = function(e)
    {
        this.DrawFlag = false;
    };
    this.OnMouseDbClk = function(e)
    {
    
    };
    
    this.DrawFlag = false;

    this.PenDc = CircPen;
}

function DcRect()
{
    this.OnMouseDown = function(e)
    {
        e = e ? e : event;
        if(!this.DrawFlag) 
        {
            this.PenDc.dotArr = null; 
            this.PenDc.dotArr = new Array();
            this.DrawFlag = true;//画线的标志为真
        }
        
        var wx  = CtnBrowser.IE ? e.clientX : e.pageX;
        var wy  = CtnBrowser.IE ? e.clientY : e.pageY;
        if(window.thisObj)
        {
            var lxy = window.logicCoordinate(wx, wy, thisObj);
            this.PenDc.dotArr[0] = new D_Dot2D(lxy[0], lxy[1], true);
        }
        else
        {
            this.PenDc.dotArr[0] = new D_Dot2D(wx, wy, false);
        }
        //this.MouseTrack[this.MouseTrack.length] = new D_Dot2D(lxy[0], lxy[1], true);
    };
    
    this.OnMouseMove = function(e)
    {
        e = e ? e : event;
        if(!this.DrawFlag) return;
        var wx  = CtnBrowser.IE ? e.clientX : e.pageX;
        var wy  = CtnBrowser.IE ? e.clientY : e.pageY;
        if(window.thisObj)
        {
            var lxy = window.logicCoordinate(wx, wy, thisObj);
            //this.PenDc.radius = Math.sqrt((lxy[0] - this.PenDc.C_Dot.lx) * (lxy[0] - this.PenDc.C_Dot.lx) + (lxy[1] - this.PenDc.C_Dot.ly) * (lxy[1] - this.PenDc.C_Dot.ly));
            this.PenDc.dotArr[1] = new D_Dot2D(lxy[0], lxy[1], true);
            this.PenDc.Draw();
        }
        else
        {
            this.PenDc.dotArr[1] = new D_Dot2D(wx, wy, false);
            this.PenDc.Draw();
        }
    };
    
    this.OnMouseUp = function(e)
    {
        this.DrawFlag = false;
        //this.PenDc.dotArr = null;
        //this.PenDc.UnDraw();
    };
    
    this.DelGragph = function()
    {
        this.PenDc.dotArr = null;
        this.PenDc.UnDraw();
    }
    
    this.OnMouseDbClk = function(e)
    {
        
    };
    
    this.DrawFlag = false;

    this.PenDc = RectPen;
}

function clearRect()
{
    window.RectPener.DelGragph();
}